package org.mch.swingm.core;

import java.awt.Insets;

import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.JToggleButton;

public class MToggleButton extends JToggleButton {
	private static final long serialVersionUID = -1630875486019045920L;

	private Object userObj;

	public MToggleButton() {
		this(null, null, false);
	}

	public MToggleButton(Icon icon) {
		this(null, icon, false);
	}

	public MToggleButton(Icon icon, boolean selected) {
		this(null, icon, selected);
	}

	public MToggleButton(String text) {
		this(text, null, false);
	}

	public MToggleButton(String text, boolean selected) {
		this(text, null, selected);
	}

	public MToggleButton(Action a) {
		this();
		setAction(a);
	}

	public MToggleButton(String text, Icon icon) {
		this(text, icon, false);
	}

	public MToggleButton(String text, Icon icon, boolean selected) {
		super(text, icon, selected);
	}

	@Override
	protected void init(String text, Icon icon) {
		super.init(text, icon);
		m_Init(text, icon);
	}

	protected void m_Init(String text, Icon icon) {
		this.userObj = text;
		setMargin(new Insets(0, 0, 0, 0));
	}

	public void setMarginInsets(int insets) {
		setMargin(new Insets(insets, insets, insets, insets));
	}

	public Object getUserObj() {
		return userObj;
	}

	public void setUserObj(Object userObj) {
		this.userObj = userObj;
	}
}
